﻿<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeFile="TemplateEdit.aspx.cs" Inherits="WebAdmin_TemplateEdit" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    
</head>
<body>
    <form id="form1" runat="server">
    Loading...
    
    <CKEditor:CKEditorControl EnterMode="BR"   IgnoreEmptyParagraph="false"   ExtraPlugins="sections"
        HtmlEncodeOutput="false" ID="elm1" 
        FilebrowserBrowseUrl="../FileManager/Default.aspx"  runat="server" ToolbarFull="Source|-|Save|NewPage|Preview|-|Templates
Cut|Copy|Paste|PasteText|PasteFromWord|-|Print|SpellChecker|Scayt
Undo|Redo|-|Find|Replace|-|SelectAll|RemoveFormat
Form|Checkbox|Radio|TextField|Textarea|Select|Button|ImageButton|HiddenField
/
Bold|Italic|Underline|Strike|-|Subscript|Superscript
NumberedList|BulletedList|-|Outdent|Indent|Blockquote|CreateDiv
JustifyLeft|JustifyCenter|JustifyRight|JustifyBlock
BidiLtr|BidiRtl
Link|Unlink|Anchor
Image|Flash|Table|HorizontalRule|Smiley|SpecialChar|PageBreak|Iframe
/
Styles|Format|Font|FontSize
TextColor|BGColor
Maximize|ShowBlocks|-|Section|-|About"  
        ></CKEditor:CKEditorControl>
        <input id="hidRemoveSection" name="hidRemoveSection" type="hidden" />
    <script type="text/javascript">
        function ExecuteCommand(commandName) {
            // Get the editor instance that we want to interact with.
            var oEditor = CKEDITOR.instances.elm1;

            // Check the active editing mode.
            if (oEditor.mode == 'wysiwyg') {
                // Execute the command.
                // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#execCommand
                oEditor.execCommand(commandName);
            }
            else
                alert('You must be in WYSIWYG mode!');
        }
        function ConfirmSectionRemove(confirmText) {
            if (confirm(confirmText)) {
                document.getElementById('hidRemoveSection').value = "Yes";
                document.forms[0].submit();
            } else
                self.close();
        }
        var emptyDivFilter =
         {
             elements: {
                 div: function (div) {

                     if (div.attributes['class'] != undefined && div.attributes['class'].indexOf('clear-both') != -1) {
                         // Peak the element content.
                         var writer = new CKEDITOR.htmlParser.basicWriter();
                         div.writeChildrenHtml(writer);
                         var innerHTML = writer.getHtml();
                         
                         // Remove the filler node if block is empty.
//                         if (CKEDITOR.tools.trim(innerHTML).match(/^(?:&nbsp;|\xa0|<br \/>)$/))
//                             div.children = [];
                        // div.children = [innerHTML];
                     }
                     return div;
                 }
             }
         };
         function test(evt) {
             var editor = evt.editor;
             var htmlFilter = editor.dataProcessor.htmlFilter,
                     dataFilter = editor.dataProcessor.dataFilter;

             // Give the filters lower priority makes it get applied after the default ones.
             htmlFilter.addRules(emptyDivFilter, 100);
             dataFilter.addRules(emptyDivFilter, 100);
            
         }
          
    </script>
    </form>
</body>
</html>
